<%@page import="cn.sendto.model.StudentEntity"%>
<%@page import="cn.sendto.model.ClassEntity"%>
<%@page import="java.util.List"%>
<%@page import="cn.sendto.mapper.IRowMapper"%>
<%@page import="cn.sendto.mapper.StudentMapper"%>
<%@page import="cn.sendto.mapper.ClassMapper"%>
<%@page import="cn.sendto.dbhelper.DBHelper"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
	<%
   if(request.getSession().getAttribute("user")==null){
	   request.getRequestDispatcher("login.jsp").forward(request, response);
   }

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script>
			function aaa(){
				return confirm("确定删除吗？")
			}
</script>
<style type="text/css">
.aaa{
	font-size: 25px;
	color: #DC143C;
	margin-right: 10%;
	text-decoration: none;
	
}
.aaa:hover{
	position: relative;
	top: 2px;
	right: 2px;
	color: #A52A2A;
}
</style>
<link rel="stylesheet" href="css/main.css" />
</head>
<body class="student_info">
<div style="width: 100%; text-align: right; margin-top:40px; " >
<a class="aaa" href="add_student.jsp">
添加学生
</a>
</div>
	<div class="student_info_div">
		<ul>
			<li>序号</li>
			<li>姓名</li>
			<li>性别</li>
			<li>年龄</li>
			<li>学号</li>
			<li>地址</li>
			<li>电话</li>
			<li>班级</li>
			<li>成绩</li>
			<li>修改</li>
			<li>删除</li>
		</ul>
		<%
	//标签名
	  String str4=">";
	  String str1="<ul><li";
	  String str2="</li><li";
	  String str3="</li></ul>";
	  //实例化
	  DBHelper helper=new DBHelper();
	  IRowMapper mapper=new StudentMapper();
	  final String QUERY="select * from studentinfo s,classinfo c where s.classid=c.classid";
	  //final String QUERY="select * from studentinfo ORDER BY studentid DESC";
	  //执行查询语句并返回
	  List<StudentEntity> list=helper.executeQuery(QUERY,mapper,null);
	  
		  System.out.print("11111111111111");
		  for(int i=0;i<list.size();i++){
			 /* String className="";
			  IRowMapper classMapper=new ClassMapper();
			  final String CLASSQUERY="select * from classinfo where classid=?";
			  List<ClassEntity> classList=helper.executeQuery(CLASSQUERY,classMapper,list.get(i).getClassId());
			  if(classlist.size()!=0){
				  className=classList.get(0).getClassName();
			  }*/
			  String qurey=str1+str4+(i+1)
					  +str2+str4+list.get(i).getStudentName()
					  +str2+str4+list.get(i).getGender()
					  +str2+str4+list.get(i).getAge()
					  +str2+" title="+list.get(i).getStudentno()+str4+list.get(i).getStudentno()
					  +str2+" title="+list.get(i).getAddress()+str4+list.get(i).getAddress()
					  +str2+" title="+list.get(i).getTel()+str4+list.get(i).getTel()
					  +str2+" title="+list.get(i).getClassName()+str4+list.get(i).getClassName()
					  +str2+str4+"<a href=\"score_info.jsp?id="+list.get(i).getStudentId()+""+"\">成绩</a>"
					  +str2+str4+"<a href=\"modifi.jsp?id="+list.get(i).getStudentId()+""+"\">修改</a>"
					  +str2+str4+"<a href=\"delete.jsp?id="+list.get(i).getStudentId()+"\" onclick=\"return aaa()\" >删除</a>"
					  +str3;
			  out.print(qurey);
		  }
	  helper.close();
	%>
	</div>
</body>
</html>